﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Collections;

namespace QLBN
{
    class DangNhap
    {
        DBConnector dbc = new DBConnector();
        private String _username;

        public String Username
        {
            get { return _username; }
            set { _username = value; }
        }

        private int _role;

        public int Role
        {
            get { return _role; }
            set { _role = value; }
        }

        internal Boolean Kiem_tra_dang_nhap(String username, String pass)
        {
            String sql = "Select * from NguoiDung";


            OleDbDataReader reader = dbc.executeReader(sql);
            while (reader.Read())
            {
                if (Comparer.Equals(reader["UserName"].ToString(), username))
                {
                    if (Comparer.Equals(reader["Pass"].ToString(), pass))
                    {
                        _username = username;
                        _role = int.Parse(reader["Role"].ToString());
                        return true;
                    }
                }
            }

            return false;
           
        }
    }
}
